package com.skz.web;

import cn.zhouyafeng.itchat4j.Wechat;
import cn.zhouyafeng.itchat4j.api.WechatTools;
import com.skz.handler.AbstractIMsgHandlerFace;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author: 宋开宗
 * @create: 2019-03-11 18:47
 **/
@RestController
@RequestMapping("/login")
public class LoginController {
    @Value("${qrPath}")
    private String qrPath;

    @GetMapping
    public ResponseEntity login() {
        Wechat wechat = new Wechat(new AbstractIMsgHandlerFace() {

        }, qrPath);
        wechat.start();
        return ResponseEntity.ok("success");
    }

    @GetMapping("/status")
    public boolean getStatus() {
        return WechatTools.getWechatStatus();
    }
}
